home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-10-04 | 4.9 KB | 161 lines |
- package sub_arctic.anim;
-
- import sub_arctic.input.event;
-
- /**
- * This is a version of the transition object which knows how to
- * talk to objects which are of type simple_animatable.<p>
- *
- * @author Ian Smith
- */
- public class simple_transition extends transition {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * This is the object we are going to animate. The "target" of this
- * transition is null since we are not using the animatable
- * interface.
- */
- protected simple_animatable _simple_target;
-
- /**
- * The simple target of this transition is the simple_animatable
- * object with whom we are communicating.
- */
- public simple_animatable simple_target() { return _simple_target;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Create a simple transition given a simple_animatable object,
- * a time interval, and a trajectory.<p>
- *
- * @param simple_animatable i the target of the animation or transition
- * @param time_interval t the time interval over which this transition occurs
- * @param trajectory j the trajectory over which this transition is mapped
- */
- public simple_transition(simple_animatable i, time_interval t,
- trajectory j) {
- super(null,t,j);
- _simple_target=i;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Start a transition. This is where the work gets done of calling the
- * start_transition function on the interactor.
- *
- * @param event e the animation event that caused things to get going
- * @param Object user_info the object passed to the animation agent when
- * the animatable joined its focus set
- */
- public void start(event e,Object user_info) {
- Object result;
-
- /* set the last time seen */
- _last_time=0.0;
-
- /* compute the result using the trajectory */
- if (traj()==null) {
- result=null;
- } else {
- result=traj().object_for_parm(0.0);
- }
-
- /* make the call to start him */
- simple_target().start_transition(result);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Perform a step... this sends the transition_step message to the
- * interactor.<p>
- *
- * @param event e the animation event for this step
- * @param Object user_info the object passed to the animation agent when
- * the animatable joined its focus set
- * @param long current_time the time it is "now" for this time step
- */
- public void step(event e, Object user_info, long current_time) {
- Object start_result, end_result;
- double c_time;
- time_interval i=interval();
- long diff_time;
-
- /* how far past the start are we*/
- diff_time=current_time-(i.start_time());
-
- /* are we past the end or at it?*/
- if (current_time>=i.end_time()) {
-
- /* set the flag that we are finished */
- _finished=true;
- return;
- }
-
- /* compute the actual time as a real */
- c_time=(double)diff_time/((double)(i.duration()));
-
- /* now compute the two objects via the trajectory */
- if (traj()==null) {
- start_result=null;
- end_result=null;
- } else {
- start_result=traj().object_for_parm(_last_time);
- end_result=traj().object_for_parm(c_time);
- }
-
- /* send the message to the interactor */
- simple_target().transition_step(start_result,end_result);
-
- /* now reset what time we have seen */
- _last_time=c_time;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Send the end message to the interactor.
- * @param event e the animation event for this step
- * @param Object user_info the object passed to the animation agent when
- * the animatable joined its focus set
- */
- public void end(event e, Object user_info) {
- Object start_result, end_result;
-
- /* compute the two objects via the trajectory */
- if (traj()==null) {
- start_result=null;
- end_result=null;
- } else {
- start_result=traj().object_for_parm(_last_time);
- end_result=traj().object_for_parm(1.0);
- }
-
- /* send the message to the interactor */
- simple_target().end_transition(start_result,end_result);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-